
var QS_Forex_CRT_Tip_Plugin=function(container){
    this.container = container;
    this.tipEl=null;
    this.tipCellEls={};
	this.lg=QS_Lang.forexCRT;
    this.init();
};
QS_Forex_CRT_Tip_Plugin.prototype = {
    init:function(){
        this.tipEl = $(this.getHTML()).appendTo(this.container);
        this.tipCellEls["bid"]=this.tipEl.find("span[key='bid']");
        this.tipCellEls["ask"]=this.tipEl.find("span[key='ask']");
        this.tipCellEls["ticker"]=this.tipEl.find("span[key='ticker']");
        this.tipCellEls["date"]=this.tipEl.find("span[key='date']");
        this.tipCellEls["open"]=this.tipEl.find("span[key='open']");
        this.tipCellEls["high"]=this.tipEl.find("span[key='high']");
        this.tipCellEls["close"]=this.tipEl.find("span[key='close']");
        this.tipCellEls["low"]=this.tipEl.find("span[key='low']");
        this.tipCellEls["chg"]=this.tipEl.find("span[key='chg']");
        this.tipCellEls["chg%"]=this.tipEl.find("span[key='chg%']");
    },
    getHTML:function(){
        return "<ul class='forexcrt-cell-tip'><li class='tip-header'><label>"+this.lg["label_forex"]+":</label><span key='ticker'></span><label>"+this.lg["label_date"]+":</label><span key='date'></span></li><li><label>"+this.lg["label_bid"]+":</label><span key='bid'></span><label>"+this.lg["label_ask"]+":</label><span key='ask'></span></li><li><label>"+this.lg["label_open"]+":</label><span key='open'></span><label>"+this.lg["label_high"]+":</label><span key='high'></span></li><li><label>"+this.lg["label_close"]+":</label><span key='close'></span><label>"+this.lg["label_low"]+":</label><span key='low'></span></li><li><label>"+this.lg["label_chg"]+":</label><span key='chg'></span><label>"+this.lg["label_chg%"]+":</label><span key='chg%'></span></li></ul>";
    },
    showTip:function(data,cell,x,y){
        var self = this;
        var pos = cell.el.position();
        self.tipEl.show();
        var left = pos.left + cell.el.width() + 10;
        if ((220 + cell.el.offset().left + cell.el.width()) > $(window).width()) {
            left = pos.left - 210;
        }
    },
    hide:function(){
        this.tipEl.hide();
    },
    show:function(position,data){
        this.tipEl.show();
        this.tipEl.css({
            "top": position.y,
            "left": position.x
        });
        this.tipCellEls["ticker"].html(data.ticker);
        this.tipCellEls["date"].html(data.Date);
        this.tipCellEls["bid"].html(data.BidPrice);
        this.tipCellEls["ask"].html(data.AskPrice);
        this.tipCellEls["open"].html(data.OpenPrice);
        this.tipCellEls["high"].html(data.HighPrice);
        this.tipCellEls["close"].html(data.ClosePrice);
        this.tipCellEls["low"].html(data.LowPrice);
        this.tipCellEls["chg"].html(data.Chg);
        this.tipCellEls["chg%"].html(data["Chg%"]);
    }
};